package com.pinda.controller;


import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
import com.github.pagehelper.PageInfo;
import com.pinda.base.entity.PdFleet;
import com.pinda.base.entity.PdTruckType;
import com.pinda.base.search.PdTruckTypeSearch;
import com.pinda.commonutils.Page;
import com.pinda.commonutils.Result;
import com.pinda.commonutils.StatusCode;

import com.pinda.service.IPdTruckTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 车辆类型表 前端控制器
 * </p>
 *
 * @author lc
 * @since 2023-06-14
 */
@RestController
@RequestMapping("/pd_truck_type")
public class PdTruckTypeController {


    @Autowired
    IPdTruckTypeService iPdTruckTypeService;


    /**
     * 查询所有的车俩类型
     * @return
     */
    @RequestMapping("/queryAllTruckType")
    public Result queryAllTruckType(){
        List<PdTruckType> list = this.iPdTruckTypeService.list();
        if(!list.isEmpty()){
            return new Result(true, StatusCode.OK,"查询成功",list);
        }
        return new Result(false,StatusCode.ERROR,"查询失败",list);
    }

    /**
     * 删除车型
     * @param id
     * @return
     */
    @GetMapping("delTruckTypeById")
    public boolean delpdTruckTypeById(String id){
        return iPdTruckTypeService.removeById(id);
    }

    /**
     * 添加车型
     * @param pdTruckType
     * @return
     */
    @PostMapping("addTruckType")
    public boolean addTruckType(@RequestBody PdTruckType pdTruckType){
        return iPdTruckTypeService.save(pdTruckType);
    }

    /**
     * 修改车型
     * @param pdTruckType
     * @return
     */
    @PostMapping("updTruckTypeById")
    public boolean updFleet1(@RequestBody PdTruckType pdTruckType){
        return  iPdTruckTypeService.updateById(pdTruckType);
    }


    /**
     * 查询车型
     * @param page
     * @return
     */
    @PostMapping("findTruckType")
    public PageInfo<PdTruckType> findTruckType(@RequestBody Page<PdTruckTypeSearch> page){
        return iPdTruckTypeService.findTruckTypeService(page);
    }

}
